using System.Web.UI;
using System.Web.UI.HtmlControls;

namespace FluentTags
{

    public class OLTag : Tag<OLTag>
    {
        public OLTag() : base("ol"){}
        
        
        public OLTag(Control control) : this()
        {
            Controls.Add(control);
        }
        
        
        
        
        public LITag<OLTag> LI()
        {
            var ctrl = new LITag<OLTag>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public OLTag LI(LITag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public LITag<OLTag> LI(string text)
        {
            var ctrl = new LITag<OLTag>(this);
            Controls.Add(ctrl);
            LiteralControl lc = new LiteralControl(text);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public LITag<OLTag> LI(Control control)
        {
            var ctrl = new LITag<OLTag>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public LITag<OLTag> LI(object value)
        {
            return LI(SafeString(value));
        }
        
        
    }

    public class OLTag<ParentType> : ChildTag<OLTag<ParentType>, ParentType>
        where ParentType : HtmlGenericControl
    {
        public OLTag(ParentType parent) : base("ol", parent) { }

        
        
        
        public LITag<OLTag<ParentType>> LI()
        {
            var ctrl = new LITag<OLTag<ParentType>>(this);
            Controls.Add(ctrl);
            return ctrl;
        }

        public OLTag<ParentType> LI(LITag child)
        {
            Controls.Add(child);
            return this;
        }
        
        public LITag<OLTag<ParentType>> LI(string text)
        {
            var ctrl = new LITag<OLTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(text);
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            
            return ctrl;
        }

        public LITag<OLTag<ParentType>> LI(Control control)
        {
            var ctrl = new LITag<OLTag<ParentType>>(this);
            Controls.Add(ctrl);
            ctrl.Controls.Add(control);
            
            return ctrl;
        }

        public LITag<OLTag<ParentType>> LI(object value)
        {
            var ctrl = new LITag<OLTag<ParentType>>(this);
            LiteralControl lc = new LiteralControl(SafeString(value));
            Controls.Add(ctrl);
            ctrl.Controls.Add(lc);
            return ctrl;
        }
        
        
        
    }
}